
#include "stdafx.h"
#include "WicBitmapFrameDecode.h"

//==============================================================================
// CWicBitmapFrameDecode
//==============================================================================

CWicBitmapFrameDecode::CWicBitmapFrameDecode(IWICBitmapFrameDecode *pIBitmapFrame) : CWicBitmapSource()
{
    m_pIWICFrameDecode = pIBitmapFrame;
}

CWicBitmapFrameDecode::CWicBitmapFrameDecode(CWicBitmapDecoder* pBitmapDecoder, UINT uIndex) : CWicBitmapSource()
{
    m_pIWICFrameDecode = NULL;
    pBitmapDecoder->GetFrame(uIndex, &m_pIWICFrameDecode);
}

CWicBitmapFrameDecode::~CWicBitmapFrameDecode()
{
    if(m_pIWICFrameDecode)
    {
        m_pIWICFrameDecode->Release();
    }
    m_pIWICFrameDecode = NULL;
}

CWicBitmapFrameDecode::CWicBitmapFrameDecode(CWicBitmapFrameDecode const & obj) : CWicBitmapSource()
{
    m_pIWICFrameDecode = obj.m_pIWICFrameDecode;
    m_pIWICFrameDecode->AddRef();
}

CWicBitmapFrameDecode& CWicBitmapFrameDecode::operator=(CWicBitmapFrameDecode const & objBitmapFrameDecode)
{
    if(m_pIWICFrameDecode)
    {
        m_pIWICFrameDecode->Release();
    }
    ClearPtr();
    m_pIWICFrameDecode = objBitmapFrameDecode.m_pIWICFrameDecode;
    m_pIWICFrameDecode->AddRef();
    return *this;
}

//==============================================================================
// IWICBitmapFrameDecode
//==============================================================================
HRESULT CWicBitmapFrameDecode::GetMetadataQueryReader( 
    /* [out] */ __RPC__deref_out_opt IWICMetadataQueryReader **ppIMetadataQueryReader)
{
    return m_pIWICFrameDecode->GetMetadataQueryReader(ppIMetadataQueryReader);
}

HRESULT CWicBitmapFrameDecode::GetColorContexts( 
    /* [in] */ UINT cCount,
    /* [size_is][unique][out][in] */  IWICColorContext **ppIColorContexts,
    /* [out] */ __RPC__out UINT *pcActualCount)
{
    return m_pIWICFrameDecode->GetColorContexts(cCount, ppIColorContexts, pcActualCount);
}

HRESULT CWicBitmapFrameDecode::GetThumbnail( 
    /* [out] */ __RPC__deref_out_opt IWICBitmapSource **ppIThumbnail)
{
    return m_pIWICFrameDecode->GetThumbnail(ppIThumbnail);
}

